/*   1:    */ package com.atomikos.icatch.system;
/*   2:    */ 
/*   3:    */ import com.atomikos.icatch.CompositeTerminator;
/*   4:    */ import com.atomikos.icatch.CompositeTransaction;
/*   5:    */ import com.atomikos.icatch.CompositeTransactionManager;
/*   6:    */ import com.atomikos.icatch.ExportingTransactionManager;
/*   7:    */ import com.atomikos.icatch.HeuristicMessage;
/*   8:    */ import com.atomikos.icatch.ImportingTransactionManager;
/*   9:    */ import com.atomikos.icatch.Propagation;
/*  10:    */ import com.atomikos.icatch.RollbackException;
/*  11:    */ import com.atomikos.icatch.SubTxCode;
/*  12:    */ import com.atomikos.icatch.SysException;
/*  13:    */ import com.atomikos.icatch.TransactionControl;
/*  14:    */ 
/*  15:    */ public class SubTxThread
/*  16:    */   extends Thread
/*  17:    */ {
/*  18:    */   private SubTxCode myCode;
/*  19:    */   private Waiter myWaiter;
/*  20:    */   private Exception myException;
/*  21:    */   private CompositeTransaction parent;
/*  22:    */   private Propagation propagation;
/*  23:    */   private HeuristicMessage msg;
/*  24:    */   
/*  25:    */   public SubTxThread(Waiter w, SubTxCode code, HeuristicMessage tag)
/*  26:    */     throws SysException
/*  27:    */   {
/*  28: 75 */     this.parent = Configuration.getCompositeTransactionManager().getCompositeTransaction();
/*  29:    */     
/*  30:    */ 
/*  31:    */ 
/*  32:    */ 
/*  33: 80 */     this.msg = tag;
/*  34:    */     try
/*  35:    */     {
/*  36: 82 */       this.propagation = Configuration.getExportingTransactionManager().getPropagation();
/*  37:    */     }
/*  38:    */     catch (RollbackException e)
/*  39:    */     {
/*  40: 85 */       throw new SysException("Transaction already rolled back");
/*  41:    */     }
/*  42: 87 */     this.myWaiter = w;
/*  43: 88 */     this.myWaiter.incActives();
/*  44: 89 */     this.myCode = code;
/*  45: 90 */     this.myException = null;
/*  46:    */   }
/*  47:    */   
/*  48:    */   public Exception getException()
/*  49:    */   {
/*  50: 96 */     return this.myException;
/*  51:    */   }
/*  52:    */   
/*  53:    */   public void run()
/*  54:    */   {
/*  55:101 */     CompositeTransaction ct = null;
/*  56:    */     try
/*  57:    */     {
/*  58:103 */       ct = Configuration.getImportingTransactionManager().importTransaction(this.propagation, true, false);
/*  59:    */       
/*  60:105 */       ct.getTransactionControl().setTag(this.msg);
/*  61:106 */       if (this.propagation.isSerial()) {
/*  62:107 */         this.myWaiter.getToken();
/*  63:    */       }
/*  64:108 */       this.myCode.exec();
/*  65:    */       
/*  66:    */ 
/*  67:111 */       ct.getTransactionControl().getTerminator().commit();
/*  68:    */     }
/*  69:    */     catch (Exception e)
/*  70:    */     {
/*  71:113 */       this.myWaiter.incAbortCount();
/*  72:114 */       this.myException = e;
/*  73:115 */       ct.getTransactionControl().getTerminator().rollback();
/*  74:    */     }
/*  75:    */     finally
/*  76:    */     {
/*  77:117 */       if (this.propagation.isSerial()) {
/*  78:118 */         this.myWaiter.giveToken();
/*  79:    */       }
/*  80:119 */       this.myWaiter.decActives();
/*  81:    */     }
/*  82:    */   }
/*  83:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\transactions\3.7.0\transactions-3.7.0.jar
 * Qualified Name:     com.atomikos.icatch.system.SubTxThread
 * JD-Core Version:    0.7.0.1
 */